<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
    <meta charset="UTF-8" />
    <title>Title</title>
    <script src="js/jquery.min.js"></script>
    <script src="js/jquery.form.min.js"/>
    <script language="JavaScript">

         function message()
        {
        var se=confirm("该文件已存在，是否覆盖？");
        if (se==true){
             var _filename = $('#filename').val();
             var _file = $('#file').val();
             var _file1 = $('#file1').val();
             var _file2 = $('#file2').val();
                 var _url = '/saveFileToServer';
                 var formData = new FormData($('#saveFileToServer')[0]);
                 $.ajax({
                    url: _url,
                    type:'POST',
                    data:formData,
                    async:false,
                    cache:false,
                    contentType:false,
                    processData:false,
                    success:function(data){
                        if(data == "文件上传成功"){
                            alert("文件上传成功！");
                        }
                        else if(data == "尚未选择模型文件"){
                            alert("尚未选择模型文件！");
                        }
                        else if(data == "尚未选择配置文件"){
                            alert("尚未选择配置文件！");
                        }
                        else if(data == "尚未选择参数文件"){
                            alert("尚未选择参数文件！");
                        }
                    },
                    error:function(data){
                        alert(data);
                    }
                 });
          }
        else{
            alert("已中断上传文件！");
        }
        }

        function submitFileName(){
             var _filename = $('#filename').val();
             var _file = $('#file').val();
             var _file1 = $('#file1').val();
             var _file2 = $('#file2').val();
             if(_filename == "" || _filename == undefined || _filename == null){
                alert("尚未输入模型编码！");
             }
             else
             {
                 var _url = '/Message';
                 <!--var formData = new FormData();  -->
                 <!--formData.append('filename',$('#filename').val());-->
                 <!--formData.append('file',$('#file').val());-->
                 <!--formData.append('file1',$('#file1').val());-->
                 <!--formData.append('file2',$('#file2').val());-->
                 var formData = new FormData($('#saveFileToServer')[0]);
               $.ajax({
                    url: _url,
                    type:'POST',
                    <!--dataType:'multipart/form-data',-->
                    <!--data:{"filename":_filename,"file":_file,"file1":_file1,"file2":_file2},-->
                    data:formData,
                    async:false,
                    cache:false,
                    contentType:false,
                    processData:false,
                    success:function(data){
                        if(data == "是否覆盖原有文件夹"){
                            message();
                        }
                        else if(data == "文件上传成功"){
                            alert("文件上传成功！");
                        }
                        else if(data == "尚未选择模型文件"){
                            alert("尚未选择模型文件！");
                        }
                        else if(data == "尚未选择配置文件"){
                            alert("尚未选择配置文件！");
                        }
                        else if(data == "尚未选择参数文件"){
                            alert("尚未选择参数文件！");
                        }
                    },
                    error:function(data){
                        alert(data);
                    }
                 });

             }
        }

    </script>
</head>
<body>

<div>pcFileUpload</div>
<!--<input type="button" name="button" value="返回" onclick="javascript:history.go(-1)"/>
 <form method="POST" enctype="multipart/form-data" action="/Message">
  <p>模型编码：<input type="text" name="filename" id="filename" onchange="submitFileName()"/></p>
</form> -->

<form method="POST" enctype="multipart/form-data" id="saveFileToServer">
    <p>模型编码：<input type="text" name="filename" id="filename" /></p>
    <p>模型文件：<input type="file" name="file" id="file" /></p>
    <p>配置文件：<input type="file" name="file1" id="file1" /></p>
    <p>参数文件：<input type="file" name="file2" id="file2" /></p>
    <p><input type="button" value="上传" onclick="submitFileName()" /></p>
</form>
<a href="/downloadzip?MODEL=ANTA24">图片下载</a>

</body>
</html>


